﻿using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel.DataAnnotations;
using SacNetUG.Areas.Forum.Models;
using SacNetUG.Areas.Forum.Models.Abstract;
using SacNetUG.Areas.Forum.Models.Concrete;

namespace SacNetUG.Areas.Forum.Models
{
    [Table(Name = "Posts")]
    public class Post
    {
        [Column(IsPrimaryKey = true, IsDbGenerated=true, AutoSync = AutoSync.OnInsert)]
        public int PostID { get; set; }

        [Column]
        //  at present we will request a 'Handle' (a person identifier) from the person submitting a subject or post
        //  if no 'Handle' is submitted, we will assign a value of 'anon' to this Property
        [StringLength(10)]
        public string PostorHandle { get; set; }

        [Column]
        public string DatePosted { get; set; }

        [Column]
        public int NumberOfPosts { get; set; }

        [Column]
        public bool Flagged { get; set; }

        [Column]
        public bool FlaggedThenApproved { get; set; }

        [Column]    //we would like to require this for entering a subject, but model binding gives an error when creating a single post,
                    //so when a subject is not submitted with the full post, we will extract the first 160 characters of the full post
        //[Required(ErrorMessage = "Please enter a short 'Subject' for your question or comments (about 10 words max)")][StringLength(200)]
        [StringLength(80)]
        public string InitialPostSubject { get; set; }

        [Column]
        [StringLength(800)]
        [Required(ErrorMessage = "Enter your comments or question for discussion by the forum (about 100 words max)")]
       public string ThePost { get; set; }

        [Column]
        public bool IsTheInitialPost { get; set; }

        [Column]
        public int PostedTo { get; set; }
    }
}